﻿using System.Collections;
using System.Collections.Generic;
using System; 
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;

public class ConfigManager : MonoBehaviour
{
     string configpath;

     public string filename="config.ini";

 
    void Start()
    {
         // 从配置文件读取
          configpath = Application.dataPath + "/config.ini";//打包好的“xxx_Data”目录貌似没有读取里面的文件权限
        //所以对于打包的程序，需要把配置文件config.ini放在exe同目录下
#if !UNITY_EDITOR
    configpath = System.Environment.CurrentDirectory + "/config.ini";
#endif 

    }
     
     ConfigIni open(string name =null){
                if(name==null)
                   return openConfig(configpath+"/"+filename);

        
               return openConfig(configpath +"/"+name);
     }

    ConfigIni openConfig(string filename){
      if (File.Exists(filename)) 
            return  new ConfigIni(filename);
        return null;
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
